package org.springblade.modules.teambition.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springblade.core.mp.support.Query;
import org.springblade.core.tool.api.R;
import org.springblade.modules.teambition.res.TaskRes;
import org.springblade.modules.teambition.res.TaskStatusRes;
import org.springblade.modules.teambition.res.TaskStepRes;
import org.springblade.modules.teambition.service.TeambitionService;
import org.springblade.modules.teambition.vo.OrderSearchVo;
import org.springblade.modules.teambition.vo.OrderVo;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;

import java.util.List;
import java.util.Map;

/**
 * 首页
 *
 * @author zhuangqian
 */
@ApiIgnore
@RestController
@RequestMapping("/team-bition")
@AllArgsConstructor
@Api(value = "teambition", tags = "teambition")
public class TeambitionController {
	private final TeambitionService teambitionService;

	@GetMapping("/auth-token")
	@ApiOperation(value = "获取auth-token")
	public R<String> getAuthToken() {
		String authToke = teambitionService.getAuthToken();
		return R.data(authToke);
	}

	@GetMapping("/projectList")
	@ApiOperation(value = "获取taskList")
	public R<List<Map<String,Object>>> projectList() {
		List<Map<String,Object>> authToke = teambitionService.getProjectList();
		return R.data(authToke);
	}


	@GetMapping("/taskList")
	@ApiOperation(value = "获取taskList")
	public R<List<TaskRes>> getTaskList() {
		List<TaskRes> authToke = teambitionService.getTaskList();
		return R.data(authToke);
	}

	@GetMapping("/taskList2")
	@ApiOperation(value = "获取taskList")
	public R<List<Map<String,Object>>> taskList2(String url) {
		List<Map<String,Object>> authToke = teambitionService.getTaskList2(url);
		return R.data(authToke);
	}

	/**
	 * 活跃用户
	 *
	 * @return
	 */
	@GetMapping("/orderList")
	@ApiOperation(value = "活跃用户", notes = "活跃用户")
	public R<IPage<TaskRes>> orderList(OrderVo orderVo, Query query) {
		IPage<TaskRes> taskRes = teambitionService.orderList(orderVo, query);
		return R.data(taskRes);
	}

	/**
	 * 活跃用户
	 *
	 * @return
	 */
	@GetMapping("/orderDetail")
	@ApiOperation(value = "活跃用户", notes = "活跃用户")
	public R<TaskRes> orderList(OrderVo orderVo) {
		TaskRes taskRes = teambitionService.orderDetail(orderVo);
		return R.data(taskRes);
	}



	/**
	 * 活跃用户
	 *
	 * @return
	 */
	@GetMapping("/taskStatusList")
	@ApiOperation(value = "活跃用户", notes = "活跃用户")
	public R<List<TaskStatusRes>> taskStatusList(OrderVo orderVo) {
		List<TaskStatusRes> taskStatusList = teambitionService.getTaskStatusList();
		return R.data(taskStatusList);
	}

	/**
	 * 活跃用户
	 *
	 * @return
	 */
	@GetMapping("/taskStatusSteps")
	@ApiOperation(value = "活跃用户", notes = "活跃用户")
	public R<List<TaskStepRes>> taskStatusSteps() {
		List<TaskStepRes> taskStatusList = teambitionService.getTaskStatusSteps();
		return R.data(taskStatusList);
	}


	/**
	 * 活跃用户
	 *
	 * @return
	 */
	@GetMapping("/searchOrder")
	@ApiOperation(value = "活跃用户", notes = "活跃用户")
	public R<TaskRes> searchOrder(OrderSearchVo orderVo) {
		TaskRes taskRes = teambitionService.searchOrder(orderVo);
		return R.data(taskRes);
	}

}
